package othersmodel

import (
	"iptv_server/v3/src/database"
)

type OthersPlayList struct {
	ID       uint `gorm:"primarykey" json:"-"`
	FolderId uint `gorm:"index" json:"-"`
	DetailId uint `gorm:"index" json:"-"`

	From         string //`json:"name,omitempty"`
	Vod_play_url string //string `json:"url"`
	// PlayerArgs   string `gorm:"type:varchar(2048)" json:"playerArgs,omitempty"`
	// PlayId string `gorm:"-" json:"vod_id"` // == ID 或 SubId非空时 ==/others/SubId/ID
}

// func GetPlays1(folderid uint, id uint) (string, string) {
// 	// Name$ID#
// 	m := make([]string, 0)

// 	// name$/-/-/id/from
// 	m = append(m, fmt.Sprintf("%s$%s/play/1/fromx", "->TO1", settings.UrlPath_TvOthers))
// 	m = append(m, fmt.Sprintf("%s$%s/play/b2/fromy", "->TO2", settings.UrlPath_TvOthers))

// 	return "others", strings.Join(m, "#")
// }

func GetPlayList(folderid uint, id uint) (play *OthersPlayList, err error) {
	// 解析服务

	play = &OthersPlayList{
		FolderId: folderid,
		DetailId: id,
		// PlayerArgs: ??,
	}

	err = database.DB.First(play).Error

	// // homevideo_model.Play{
	// // 	// url , header, parser // PlayerArgs
	// // }

	// fmt.Printf("--->play.Name: %v\n", play.Name)

	return play, err

	// return "GetPlay", nil
}

type Play struct {
	Url        string `json:"url"`
	PlayerArgs string `json:"playerArgs,omitempty"`
}

func GetPlay(id string) (play *Play, err error) {
	// 解析服务

	play = &Play{
		Url: "http://v3.tv.server.lan:19999/files/videos/group_11_tv_tv1/09_射雕_神雕/射雕英雄传(1983)/射雕英雄传（1983）S01E01.1080P.mkv",
	}

	return play, nil

	// play = &OthersPlay{
	// 	FolderId: folderid,
	// 	DetailId: id,
	// 	// PlayerArgs: ??,
	// }

	// err = database.DB.First(play).Error

	// // // homevideo_model.Play{
	// // // 	// url , header, parser // PlayerArgs
	// // // }

	// // fmt.Printf("--->play.Name: %v\n", play.Name)

	// return play, err

	// return "GetPlay", nil
}
